<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="lib/css/bootstrap.css">
</head>

<body>
    <div class="container">
        <form action="/api/user/signin" method="POST">
            <div class="form-group">
                <input type="text" name="petname" class="form-control" required placeholder="请输入昵称">
            </div>
            <div class="form-group">
                <input type="password" name="password" class="form-control" required placeholder="请输入密码">
            </div>
            <input type="submit" class="btn btn-success form-control" value="登录"></input>
        </form>
    </div>
    <script src="lib/js/jquery.js"></script>
    <script src="lib/js/bootstrap.js"></script>
    <script>
        $('form').submit(function (ev) {
            ev.preventDefault()

            var data = $(this).serialize()

            $.post('/api/user/signin', data, function (res) {
                if (res.code == 'success') {
                    location.href = '/'
                }
                else {
                    $('.modal-body').text(res.message)
                    $('.modal').modal('show')
                }
            })
        })
    </script>
</body>

</html>